import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import getting from './modules/getting'

Vue.use(Vuex)

export default new Vuex.Store({
  // strict:true,//开启语法严格模式

  state: {
    count: 101,
    list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 5, 43, 2]
  },
  getters: {
    total (state) {
      return state.list.reduce((sum, item) => sum + item, 0)
    }
  },
  mutations: {
    addHandle (state, obj) {
      state.count += obj.m
    },
    addActions (state, m) {
      state.count += m
    }
  },
  actions: {
    syncHandle (content, m) {
      setTimeout(() => {
        console.log(content, '我来了')
        content.commit('addActions', m)
      }, 1000);
    }
  },
  modules: {
    user,
    getting
  }
})
